import request from "@/utils/request";
import { AxiosPromise } from "axios";

/**
 * 拼多多账单数据
 *
 * @param queryParams
 */
export function getPddBillPage(queryParams: any): AxiosPromise<PageResult<[]>> {
	return request({
		url: '/api/v1/pddBill/page',
		method: 'get',
		params: queryParams
	});
}


/**
 * 获取拼多多账单表单数据
 *
 * @param queryParams
 */
export function getPddBillForm(id: number) {
	return request({
		url: '/api/v1/pddBill/' + id + '/form',
		method: 'get'
	});
}

/**
 * 保存拼多多账单
 *
 * @param data
 */
export function savePddBill(data: any) {
	return request({
		url: "/api/v1/pddBill",
		method: "post",
		data: data,
	});
}

/**
 * 删除拼多多账单
 *
 * @param ids
 */
export function deletePddBill(ids: string) {
	return request({
		url: '/api/v1/pddBill/' + ids,
		method: 'delete'
	});
}

/**
 * 导入拼多多账单
 *
 * @param file
 */
export function importPddBill(file: any) {
	const formData = new FormData();
	formData.append('file', file);
	return request({
		url: '/api/v1/pddBill/pddBillImport',
		method: 'post',
		data: formData,
		headers: {
			'Content-Type': 'multipart/form-data'
		}
	});
}

/**
 * 导出拼多多账单
 *
 * @param ids
 * @returns
 */
export function exportPddBill(ids: any) {
	return request({
		url: '/api/v1/pddBill/_export?ids='+ids,
		method: 'get',
		responseType: 'arraybuffer'
	});
}
